package calendar.messages;

import calendar.Event;
import calendar.User;
import edu.gmu.middleware.Message;
import edu.gmu.streams.BlockInputStream;
import edu.gmu.streams.BlockOutputStream;
import java.io.IOException;

/* this class represents a single user */
import java.util.ArrayList;
public class UpdateRequest implements Message
{
  public ArrayList users;
  public Event event;

  public UpdateRequest()
  {

  }

  public void marshal(BlockOutputStream stream) throws IOException
  {
    stream.writeInt( this.users.size() );
      for (int i = 0; i < users.size(); i++)
      {
          User user = (User)users.get(i);
          user.marshal(stream);
      }
    this.event.marshal(stream);
  }

  public void unmarshal(BlockInputStream stream) throws IOException
  {
    int size = stream.readInt();
    this.users = new ArrayList();
      for (int i = 0; i < size; i++)
      {
          User user = new User();
          user.unmarshal(stream);
          this.users.add(user);
      }
    this.event = new Event();
    this.event.unmarshal(stream);
  }
}
